package com.cy.uv.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cy.uv.enetity.Product;
import com.cy.uv.mapper.ProductMapper;
import com.cy.uv.service.Productservice;

import lombok.RequiredArgsConstructor;

import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RequiredArgsConstructor
public class ProductserviceImpl extends ServiceImpl<ProductMapper, Product> implements Productservice {


    private final ProductMapper productMapper;

    /**
     * 获取表数据的全部信息用于展示
     * @return 全部表数据
     */
    @Override
    public List<Product> getProducts() {
        return productMapper.selectList(null);
    }

    @Override
    public List<Product> getProductListPage(int pagenow,int pagesize) {
        Page<Product> page = new Page<>(pagenow,pagesize);
        IPage<Product> iPage = productMapper.selectPage(page ,null);
        return iPage.getRecords();


    }
}
